package com.google.code.server4j.connector.bio;

import java.net.Socket;
import java.util.concurrent.ConcurrentLinkedQueue;

import com.google.code.server4j.connector.ProcessAdapter;

public class BioProcessAdapter implements ProcessAdapter {

	private ConcurrentLinkedQueue<BioHttpProcessor> queue = new ConcurrentLinkedQueue<BioHttpProcessor>();
	@Override
	public boolean process(Socket socket) {
		BioHttpProcessor processor = queue.poll();
		if(processor == null) {
			processor = new BioHttpProcessor();
			processor.init();
		}
		processor.process(socket);
		queue.offer(processor);
		return false;
	}

}
